package br.gov.dpf.epol.test.designtests;

import java.util.HashSet;
import java.util.Set;

import org.designwizard.design.MethodNode;
import org.designwizard.main.DesignWizard;

public class Modules {

    private Set<MethodNode> gui;
    private Set<MethodNode> action;
    private Set<MethodNode> converter;
    private Set<MethodNode> validator;
    private Set<MethodNode> listagem;
    private Set<MethodNode> cenario;
    private Set<MethodNode> dao;
    private Set<MethodNode> session;
    private Set<MethodNode> util;

    private Set<MethodNode> test;
    private Set<MethodNode> testUnit;
    private Set<MethodNode> testIntegration;

    private Set<MethodNode> log;
    private Set<MethodNode> model;
    private Set<MethodNode> tarefa;

    private DesignWizard dw;

    public Modules(DesignWizard dw) {
	this.dw = dw;
	gui = new HashSet<MethodNode>();
	action = new HashSet<MethodNode>();
	converter = new HashSet<MethodNode>();
	validator = new HashSet<MethodNode>();
	listagem = new HashSet<MethodNode>();
	cenario = new HashSet<MethodNode>();
	dao = new HashSet<MethodNode>();
	session = new HashSet<MethodNode>();
	util = new HashSet<MethodNode>();
	test = new HashSet<MethodNode>();
	testUnit = new HashSet<MethodNode>();
	testIntegration = new HashSet<MethodNode>();
	log = new HashSet<MethodNode>();
	model = new HashSet<MethodNode>();
	tarefa = new HashSet<MethodNode>();
	
	for (MethodNode m : this.dw.getAllMethods()) {

	    //mapping each method to the its module.
	    if (m.getName().startsWith("javax.faces") || 
		    m.getName().startsWith("br.gov.dpf.epol.model.tarefa.AtributoTarefa") || 
		    m.getName().startsWith("br.gov.dpf.epol.util.SelectItemComparator") || 
		    m.getName().startsWith("br.gov.dpf.epol.util.EscapableMessagesRenderer"))
		gui.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.action.validator"))
		validator.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.action.converter") || m.getName().startsWith("br.gov.dpf.epol.util.LabelConverter"))
		converter.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.action.listagem"))
		listagem.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.action"))
		action.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.cenario"))
		cenario.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.dao"))
		dao.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.session") ||
		    m.getName().startsWith("br.gov.dpf.epol.externo.protocolo"))
		session.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.util") ||
		    m.getName().startsWith("br.gov.dpf.epol.pesquisa"))
		util.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.test.unit"))
		testUnit.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.test.integration"))
		testIntegration.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.test") && 
		    !m.getName().startsWith("br.gov.dpf.epol.test.util.Log4jUtil"))
		test.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.test.util.Log4jUtil"))
		log.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.model.tarefa"))
		tarefa.add(m);
	    else if (m.getName().startsWith("br.gov.dpf.epol.model"))
		model.add(m);
	    
	}
    }

    public Set<MethodNode> getGui() {
        return gui;
    }

    public Set<MethodNode> getAction() {
        return action;
    }

    public Set<MethodNode> getConverter() {
        return converter;
    }

    public Set<MethodNode> getValidator() {
        return validator;
    }

    public Set<MethodNode> getListagem() {
        return listagem;
    }

    public Set<MethodNode> getCenario() {
        return cenario;
    }

    public Set<MethodNode> getDao() {
        return dao;
    }

    public Set<MethodNode> getSession() {
        return session;
    }

    public Set<MethodNode> getUtil() {
        return util;
    }

    public Set<MethodNode> getTest() {
        return test;
    }

    public Set<MethodNode> getTestUnit() {
        return testUnit;
    }

    public Set<MethodNode> getTestIntegration() {
        return testIntegration;
    }

    public Set<MethodNode> getLog() {
        return log;
    }

    public Set<MethodNode> getModel() {
        return model;
    }

    public Set<MethodNode> getTarefa() {
        return tarefa;
    }
    
}